*-------------------------------------------------------------------------------
* Description: Settings
* Justin Wiltshire
*
* Updated: July 18, 2023
*-------------------------------------------------------------------------------

* Set project directory macro
global projdir "/accounts/projects/mreich/mw_benefits/ca_mw/replication"

* Build directory structure if it doesn't exist
capture mkdir "$projdir/do/build"
capture mkdir "$projdir/do/analysis"
capture mkdir "$projdir/log"
capture mkdir "$projdir/dta"
capture mkdir "$projdir/dta/build"
capture mkdir "$projdir/dta/build/src"
capture mkdir "$projdir/dta/build/cln"
capture mkdir "$projdir/dta/analysis"
capture mkdir "$projdir/out"
capture mkdir "$projdir/out/figures"
capture mkdir "$projdir/out/tables"

* Ensure allsynth is installed
ssc install allsynth, replace all

* Ensure xsvmat is installed
ssc install xsvmat, replace all

*-------------------------------------------------------------------------------
* Display settings (from Brendan Price)
*-------------------------------------------------------------------------------

* General graph appearance
set scheme lycidas1, permanently

* Fonts
graph set ps fontdir "$projdir/do/ado/fonts"
graph set eps fontdir "$projdir/do/ado/fonts"
graph set window fontface "CMU Serif"
graph set ps fontface "CMU Serif"
graph set ps fontfaceserif "CMU Serif"
graph set eps fontface "CMU Serif"
graph set eps fontfaceserif "CMU Serif"

* Specify color choices
global col1 "sea"
global col2 "cranberry"
global col3 "turquoise"
global col4 "vermillion"
global col5 "sky"
global col6 "sienna"
global col7 "purple"
global col8 "reddish"

* Grayscale
global gs "gs10"

* Line patterns
global pat1 "solid"
global pat2 "dash"
global pat3 "shortdash"
global pat4 "dash_dot"
global pat5 "solid"
global pat6 "dash"
global pat7 "shortdash"
global pat8 "dash_dot"

* Specify marker styles
global sym1 "circle"
global sym2 "diamond"
global sym3 "triangle"
global sym4 "square"
global sym5 "plus"
global sym6 "smcircle"
global sym7 "smdiamond"
global sym8 "smsquare"

* Miscellaneous
global pdfmargins = 2

* Sizing factor for paper and for slides: one-pane vs. two-pane figures
global paperscale1 = 1.00
global paperscale2 = 1.10
global slidescale1 = 1.10
global slidescale2 = 1.15


*-------------------------------------------------------------------------------
* Short programs
*-------------------------------------------------------------------------------

* Program to concatenate pdfs (author: Brendan Price)
capture program drop combine_pdfs
program define combine_pdfs
	syntax anything(name=filelist) using/ [if/] [, replace delete]
	
	* Make sure that "anything" is non-empty
	capture assert `"`filelist'"' != ""
	if _rc != 0 {
		di as error "you must supply at least one .pdf name"
	}
	
	* If replace is not specified, output file must be new
	if "`replace'" == "" {
		confirm new file `using'
	}
	
	* Combine the input files into a single pdf
	shell gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -dAutoRotatePages=/None -sDEVICE=pdfwrite -sOutputFile=`using' `filelist'
	
	* If requested, delete the input files
	if "`delete'" != "" {
		foreach f in `filelist' {
			capture rm `f'
		}
	}
end
